package com.upcode.weighing.enums;

import org.apache.commons.lang3.StringUtils;

/**
 * 机构类型枚举
 */
public enum OrgTypeEnum {

    ORG("1","机构"),
    DEP("2","部门"),
    POST("3","岗位");

    private String value;
    private String msg;

    OrgTypeEnum(String value) {
        this.value = value;
        this.msg = "";
    }

    OrgTypeEnum(String value, String dec) {
        this.value = value;
        this.msg = dec;
    }

    public String getValue() {
        return value;
    }

    public static OrgTypeEnum getValue(String value) {
        for (OrgTypeEnum u : OrgTypeEnum.values()) {
            if (u.getValue().equals(value)) {
                return u;
            }
        }
        return OrgTypeEnum.ORG;
    }

    public String getMsg() {
        return msg;
    }

    public static String getMsg(String value) {
        if (StringUtils.isBlank(value)) {
            return "";
        }
        for (OrgTypeEnum u : OrgTypeEnum.values()) {
            if (u.getValue().equals(value)) {
                return u.msg;
            }
        }
        return "";
    }

    public static String getVal(String msg) {
        if (StringUtils.isBlank(msg)) {
            return "";
        }
        for (OrgTypeEnum u : OrgTypeEnum.values()) {
            if (u.getMsg().equals(msg)) {
                return u.value;
            }
        }
        return "";
    }
}
